home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2000-01-01 | 37.3 KB | 1,107 lines
/* EZHomePrefs ** This program uses MUIRexx v3.0+ ** $VER: EZHomePrefs 1.00 © 1996-2000 by Jim Hines and Gene Heskett - EzSoft ** ** Fixed bug which prevented creating an action.prefs file when one didn't exist ** Battreset button now works. ** ** Fixed the dim gadgets bug ** Fixed another bug in the dim which was causing an exit if no status was returned. ** Added user Macro.prefs support. Eventually want to be able to record macros ** Deleted 'rx' from EZHome startup command as it is now compiled and rx is unnecessary. ** Now supports ALL statusrequest items including EZHomeD version number. ** ** v77 Battery Meter and Battery Reset Now functional ** v78 User Labels kinda working. ** v79 Commented out the 'do until rc ~= 20' code in the send. ** v80 Took out the above 'fix' as it was causing problems ** v81 Took out all references to RexxReqTools.library and replace with MUI calls ** Still one more to work out though. ** v82 Text field gadget now allows user to name units. Also sames these. Note that the ** settings are lost when switching to a new housecode UNLESS prefs were saved first. ** ** v84 Fixed bugs in prefs files routines. ** v85 Fixed empty "class" variable problem. Was always replying to a port unnecessarily. ** This problem also existed in EZCronR4b. ** v86 Now reselects the previously selected action on refreshes. ** v87 Fixed a bug that caused an error when loading a new action file. Now resets the ** last selected action to 0 ** v88 Bumped to match version of ezhome daemon ** v89 EZHome About Logo now ghosts when about window is opened. ** v89a Created batterytype vars for alkaline, NiCad and DryCell. Expermenatal at this point. ** v90 ** v91 Bug hunting, some non-lighting functions cause exits due to wrong arguments. ** Such as repeats of the talking clock translation. Obviously an un-initialized var ** someplace, but I haven't found it yet... ** v91.1 Jim Lucia reports he cannot stop it from opening the logging ** screen/window. ** v91.2 some housecleaning ** v91.3 trying to fix housecode stuffs. Got it! ** ** V 1.00! Finally ready for Prime Time ** Oops, Jim Lucia says no, and he is right! That ones fixed now 5-22-2000 GH ** 5/25/2000 trying to make gui a bit more informative, like an auto update that ** includes the dimmed status? */ VER = 'EZHomePrefs V1.00 © 1996-2000 by\n Jim Hines and Gene Heskett DBA EzSoft' SIGNAL ON ERROR SIGNAL ON IOERR SIGNAL ON SYNTAX SIGNAL ON HALT SIGNAL ON BREAK_C OPTIONS FAILAT 20 OPTIONS RESULTS if ~show('L','rexxsupport.library') then call addlib('rexxsupport.library', 0, -30) if ~show('L','rexxreqtools.library') then call addlib("rexxreqtools.library", 0, -30, 0) /* ========================== GLOBAL VARIABLES ======================== */ disclose = 0 /* troubleshooter, set to 0 if no shell is available */ LF = '0a'x mod = 0 /* Modified variable */ CM11A_Time = 'ERROR' CM11A_Day = 'ERROR' CM11A_DayNum = 'ERROR' CM11A_Rev = 'ERROR' Battimer = 0 EZHomeD_Ver = 'NA' EZHome_Reg = 'NA' user.0 = 0 en = 0 /* Selected action */ super = 262144 alk = 196608 nicad = 131072 drycel = 65536 batterytype = super dimbyte1 = '00'x dimbyte2 = '00'x devstat1 = '00'x devstat2 = '00'x /* StatusArray.1 = 'Off' StatusArray.2 = 'On' StatusArray.3 = 'Dim' */ StutusArray.0 = 'Off' StutusArray.1 = 'On' StutusArray.2 = 'Dim' /* ==========end=========== */ /* ========================== MUI VARIABLES ======================== */ TRUE = 1 FALSE = 0 MUIA_Selected = 0x8042654b MUIA_Menuitem_Shortcut = 0x80422030 MUIA_Disabled = 0x80423661 /* MUIA_Group_Columns = 0x8042f416*/ /* MUIA_Group_VertSpacing = 0x8042e1bf*/ /* MUIA_Group_SameWidth = 0x8042b3ec*/ /* MUIV_Frame_Group = 9*/ /* MUIA_Cycle_Active = 0x80421788*/ /* MUIA_Dropable = 0x8042fbce*/ MUIA_List_Quiet = 0x8042d8c7 MUIA_List_Active = 0x8042391c /* required to get number info from listview */ MUIM_List_Clear = 0x8042ad89 /* Clears listview..duh */ /* MUIV_List_GetEntry_Active = -1*/ MUIV_EveryTime = 0x49893131 MUIV_List_Insert_Bottom = -3 MUIA_List_Format = 0x80423c0a MUIA_Window_ScreenTitle = 0x804234b0 MUIM_Application_AboutMUI = 0x8042d21d /* MUI Launching Attrs */ MUIM_Application_OpenConfigWindow = 0x804299ba /* Battery Timer */ MUIA_Gauge_Current = 0x8042f0dd /* V4 isg LONG */ MUIA_Gauge_Divide = 0x8042d8df /* V4 isg BOOL */ MUIA_Gauge_Horiz = 0x804232dd /* V4 i.. BOOL */ MUIA_Gauge_Max = 0x8042bcdb /* V4 isg LONG */ /* FOR RESELECTION OF LISTS */ MUIM_List_Select = 0x804252d8 MUIV_List_Select_All = '-2' MUIV_List_Select_Off = '0' MUIV_List_Select_On = '1' /* ========================== Open EZHome.prefs here ======================== */ if exists('EZHome:prefs/EZHome.prefs') then do if disclose = 1 then say 'Reading EZHome.prefs' call open('gprefs', 'EZHome:Prefs/EZhome.prefs', R) plogpath = readln('gprefs') /*pref.1*/ pdevice = readln('gprefs') /*pref.2*/ punit = readln('gprefs') /*pref.3*/ pdefhouset = readln('gprefs') /*pref.4*/ call cvthousehex() /* Call routine to convert defhousecode from hex. pdefhouse is returned variable */ plogsw = readln('gprefs') /*pref.5*/ ptstsw = readln('gprefs') /*pref.6*/ call close('gprefs') end else do call message('EZHome.prefs file not found, using defaults') plogpath = 't:ezhlog.txt' pdevice = 'serial.device' punit = '0' pdefhouse = 'A' plogsw = '0' ptstsw = 0 end call openprefs() /* ========================== BUILD MUI GUI ======================== */ address EZHOMEMUI window ID Win1 COMMAND """QUIT""" PORT EZHOMEPREFS ATTRS MUIA_Window_ScreenTitle """EZHomePrefs MUI v1.0 ©1998-2000 EZSoft""" TITLE """EZHome - Easy home automation for Amiga.""" menu LABEL "Project" item COMMAND """ldgad""" PORT EZHOMEPREFS ATTRS MUIA_Menuitem_Shortcut L LABEL "Load" item COMMAND """svgad""" PORT EZHOMEPREFS ATTRS MUIA_Menuitem_Shortcut S LABEL "Save" item COMMAND """about""" PORT EZHOMEPREFS LABEL "About EZHome" item COMMAND '"method 'MUIM_Application_AboutMUI' 0"' PORT EZHOMEMUI LABEL "About MUI" item COMMAND '"method 'MUIM_Application_OpenConfigWindow'"' PORT EZHOMEMUI LABEL "MUI Settings" item COMMAND """QUIT""" PORT EZHOMEPREFS ATTRS MUIA_Menuitem_Shortcut Q LABEL "Quit" endmenu menu LABEL "Prefs" item COMMAND """svglb""" PORT EZHOMEPREFS LABEL "Save Prefs" endmenu if showlist('A', 'EZCRON')then do group REGISTER LABELS "RealTime,Actions,Prefs, Timer" end else group REGISTER LABELS "RealTime,Actions,Prefs" MUIA_Slider_Min = 0x8042e404 /*=========== Build Realtime Page ===========*/ MUIA_Slider_Max = 0x8042d78a MUIA_Slider_Level = 0x8042ae3a MUIA_Text_SetMax = 0x80424d0a group HORIZ group FRAME group HORIZ label "Housecode" cycle ID rcyc COMMAND """realhouse""" PORT EZHOMEPREFS LABELS "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P" endgroup group HORIZ menu LABEL "Prefs" /* Pop Up Menu */ item COMMAND """svglb""" PORT EZHOMEPREFS LABEL "Save Labels" endmenu group do qq = 1 to 16 /*if hcuser.qq = qq then iterate*/ space string ID rc.qq HELP """Name Field:\nAllows user to enter\nknown unit names.""" CONTENT hcuser.qq end endgroup group do qq = 1 to 16 /*if hcuser.qq = qq then iterate*/ space cycle ID _on||qq COMMAND _on||qq PORT EZHOMEPREFS LABELS "Off,On,Dim" end endgroup group do qq = 1 to 16 /*if hcuser.qq = qq then iterate*/ space /*if hcuser.qq = qq then popslider ID _dm||qq ATTRS MUIA_Disabled 1 else*/ popslider ID _dm||qq COMMAND _dm||qq PORT EZHOMEPREFS ATTRS MUIA_Slider_Min "-9" MUIA_Slider_Max 9 end endgroup endgroup group button COMMAND """statusreq""" PORT EZHOMEPREFS LABEL "Status Update" endgroup endgroup group FRAME button ID about COMMAND 'about' PORT EZHOMEPREFS PICT "EZHome:Images/ezs.iff" group HORIZ label "Last Selected" text ID rlast LABEL "None" endgroup button COMMAND """ralllightson""" PORT EZHOMEPREFS LABEL "AllLightsOn" button COMMAND """ralllightsoff""" PORT EZHOMEPREFS LABEL "AllLightsOff" button COMMAND """rallunitsoff""" PORT EZHOMEPREFS LABEL "AllUnitsOff" /*space*/ /*if user.0 ~= 0 then do*/ list ID LIST2 TITLE """\033b\033uQuick Macros""" COMMAND """LIST2""" PORT EZHOMEPREFS /*end*/ group HORIZ button COMMAND """addmacro""" PORT EZHOMEPREFS LABEL "Add" button COMMAND """delmacro""" PORT EZHOMEPREFS LABEL "Delete" endgroup endgroup endgroup group ATTRS MUIA_Group_SameWidth MUIV_Frame_Group /* Monitored Events Page*/ group FRAME group HORIZ label "Command" popasl ID args COMMAND """args""" PORT EZHOMEPREFS HELP """This is the command to\n be executed whenan\n X10 command is received.""" endgroup group HORIZ label "House" cycle ID hc COMMAND """hc""" PORT EZHOMEPREFS HELP """Housecode""" LABELS "-,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P" cycle ID uc COMMAND """uc""" PORT EZHOMEPREFS HELP """Unitcode""" LABELS "-,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16" label "Unit" cycle ID fnc COMMAND """fnc""" PORT EZHOMEPREFS HELP """Function""" LABELS "-,On,Off,Dim,Bright,AllLightsOn,AllUnitsOn,AllUnitsOff" label "Function" button ID adgad COMMAND """adgad""" PORT EZHOMEPREFS HELP """Adds the current Action\nto the Action list.""" LABEL "Add" endgroup group HORIZ label LEFT "Description" string ID DCSTR COMMAND """descstr""" PORT EZHOMEPREFS endgroup endgroup group list ID """LIST1""" TITLE """\033bAction List""" PORT EZHOMEPREFS HELP """Contains Descriptions of Actions.""" endgroup group FRAME group HORIZ button ID newgd COMMAND """newgd""" PORT EZHOMEPREFS HELP """Clears all fields.""" LABEL "Clear/New" button ID ldgad COMMAND """ldgad""" PORT EZHOMEPREFS HELP """Load an Action file""" LABEL "Load" button ID svgad COMMAND """svgad""" PORT EZHOMEPREFS HELP """Save an Action file""" LABEL "Save" endgroup group HORIZ button ID dlgad COMMAND """dlgad""" PORT EZHOMEPREFS HELP """Delete selected entry.""" LABEL "Delete" button ID test COMMAND """test""" PORT EZHOMEPREFS HELP """Test selected entry.""" LABEL "Test" button ID fresh COMMAND """fresh""" PORT EZHOMEPREFS HELP """Refresh ports.""" LABEL "Refresh" endgroup endgroup endgroup /*=========================Build Preferences screen======================*/ group group FRAME HORIZ label LEFT "Serial Device" string ID devgad CONTENT pdevice label "Unit" string ID unit CONTENT punit endgroup group FRAME group FRAME HORIZ label "Monitored Housecode" cycle ID hcpref COMMAND """sethouse""" PORT EZHOMEPREFS LABELS "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P" endgroup group FRAME HORIZ label "Record Log" check ID logsx COMMAND """logsx""" PORT EZHOMEPREFS ATTRS MUIA_Selected plogsw HELP """Controls whether a log\nis recorded or not.""" label "LogPath" string ID loggad CONTENT plogpath endgroup group FRAME HORIZ label 'BattType' cycle ID batyp COMMAND "batterytype" PORT EZHOMEPREFS LABELS "Standard,NiCad,Alkaline,Lithium" button ID batgd COMMAND """batgd""" PORT EZHOMEPREFS LABEL "Battery Reset" label "E" gauge ID batmt ATTRS MUIA_Gauge_Horiz MUI_Frame_Gauge MUIA_Gauge_InfoText '' MUI_Gauge_Current LABEL "Battery Level %ld" label "F" /*object CLASS '"Scale.mui"'*/ endgroup endgroup group HORIZ group FRAME button ID scgad COMMAND """scgad""" PORT EZHOMEPREFS LABEL "Set Clock" label CENTER "\033bCM11A Status" text ID CM1 text ID CM2 text ID CM3 text ID CM4 button COMMAND """statusreq""" PORT EZHOMEPREFS LABEL "Status Update" endgroup group group FRAME group HORIZ label "Test Shell" check ID tstsx COMMAND """tstsx""" PORT EZHOMEPREFS ATTRS MUIA_Selected ptstsw HELP """Determines whether or not\na console is opened when\ntesting actions.""" endgroup endgroup button ID svglb COMMAND """svglb""" PORT EZHOMEPREFS LABEL "Save Settings" endgroup endgroup endgroup endgroup group HORIZ label "EZHome Daemon Control" if showlist('P','EZHOME') then do address EZHomeMUI button ID ezhd COMMAND """ezhd""" PORT EZHOMEPREFS HELP """EZHome daemon switch""" LABEL "Active" end if ~showlist('P', 'EZHOME') then do address EZHomeMUI button ID ezhd COMMAND """ezhd""" PORT EZHOMEPREFS HELP """EZHome daemon switch""" LABEL "Inactive" end if showlist('A', 'EZCRON')then do button ID ezcron COMMAND """ezcron""" PORT EZHOMEPREFS HELP """Call EZCron Prefs""" LABEL "EZCron" end /*button ID abt COMMAND """about""" PORT EZHOMEPREFS HELP """EZHome, by \nEZSoft""" LABEL "About"*/ endgroup endwindow /*callhook ID DCSTR COMMAND """string ID DCSTR CONTENT %s""" PORT EZHOMEMUI ATTRS MUIA_List_Active MUIV_EveryTime*/ cycle ID hcpref LABELS pdefhouse /* reset the monitored housecode gad */ cycle ID rcyc LABELS pdefhouse /* reset the realtime housecode gad */ list ID LIST1 ATTRS MUIA_List_Quiet 1 /* Disable listview redraw */ do qq = 1 to next list ID LIST1 INSERT POS STRING MUIV_List_Insert_Bottom STRING pdesc.qq end if user.0 ~= 0 then do do qq = 1 to user.0 /* Write Macro Listview */ list ID LIST2 INSERT POS MUIV_List_Insert_Bottom STRING username.qq end end list ID LIST1 ATTRS MUIA_List_Quiet 0 callhook ID LIST1 COMMAND """LIST1""" PORT EZHOMEPREFS ATTRS MUIA_List_Active MUIV_EveryTime call openport('EZHOMEPREFS') if showlist('P', EZHOME) then do call statusrep() call devstatus() end /* ========================== MAIN LOOP ======================== */ waitforpkt: do forever vpkt = 0 address EZHOMEPREFS call waitpkt('EZHOMEPREFS') /* Wait for a message from the daemon */ packet = getpkt('EZHOMEPREFS') /* Get the message */ if packet ~= '00000000'x then do /* This is not a null message */ vpkt = 1 class = getarg(packet) /* Get the information about the message */ if disclose = 1 then say 'Class =' class /* This MIGHT have been Jim Lucia's auto-open shell! */ if pos('StatusReturn',class) > 0 then do if words(class) > 1 then do stat.9 = word(class, 2) stat.10 = word(class, 3) devstat1 = x2c(left(stat.9, 2)) devstat2 = x2c(right(stat.9, 2)) dimbyte1 = x2c(left(stat.10, 2)) dimbyte2 = x2c(right(stat.10, 2)) CM11A_Time = word(class, 4) CM11A_Day = word(class, 5) CM11A_DayNum = word(class, 6) CM11A_Rev = word(class, 7) battimer = word(class, 8) rethouse = word(class, 9) EZHomeD_Ver = word(class, 10) EZHome_Reg = 'EzHome 'substr(class,50+length(battimer)) /* Compensate for battertime strlen */ if vpkt = 1 then call reply(packet,0);vpkt=0 call devstatus() end end /* Actions Window */ if class = 'args' then call args() if class = 'hc' then call hc() if class = 'uc' then call uc() if class = 'fnc' then call fnc() if class = 'descstr' then call descstr2() if class = list1 then call list1() if class = 'adgad' then call adgad() if class = 'newgd' then call newgd() if class = 'dlgad' then call delete() if class = 'fresh' then call refresh(0) if class = 'refresh' then call refresh(1) if class = 'svgad' then call svgad() if class = 'ldgad' then call ldgad() if class = 'test' then call test() if class = 'ezhd' then call ezhd() if class = 'about' then call about() if class = quit then call exiting() if class = 'ezcron' then do if exists('EZCron:ezmui') then address command 'run >NIL: execute EZCron:ezmui' end /* Prefs Window */ if class = 'sethouse' then call sethouse() if class = 'svglb' then call saveprefs() if class = 'scgad' then call setclock() if class = 'batgd' then call batteryrst() /* Realtime Window */ if class = 'realhouse' then call labels() if class = list2 then call list2() if class = rdims then call rdims() /* TEMPORARY and no such function! */ /* this loop below is doing it the hard way but requires fixes in _on and _dimit for complete speedup */ /* it should be done like this: */ if pos('_',class) then do if pos('_ON',class)= 1 then do qq = substr(class,4) call _on(qq) end if pos('_DM',class)= 1 then do qq = substr(class,4) call _dimit(qq) end end if class = 'ralllightson' then call rAllLightsOn() if class = 'ralllightsoff' then call rAllLightsOff() if class = 'rallunitsoff' then call rAllUnitsOff() if class = 'statusreq' then call statusrep() /* Macro Stuff */ if class = 'addmacro' then call AddMacro() if class = cancelreq1 then call CancelWin(AddMacWindow) if class = 'delmacro' then call DelMacro() /* is dummy return */ /* Arexx Commands */ /* Misc Commands */ if class = closeabout then call closeabout() end end return /* ============================================================= */ DescStr2: address EZHOMEMUI mod = 1 string ID DCSTR ; com = result pdesc.en = com /*list ID LIST1 INSERT POS en STRING MUIV_List_Insert_Bottom pdesc.i*/ if vpkt = 1 then call reply(packet,0);vpkt=0 call refresh() return list1: address EZHOMEMUI list ID LIST1 ATTRS MUIA_List_Active en = RESULT+1 /* en is the event number */ list ID LIST1 ; desc = result popasl ID args CONTENT pcommand.en cycle ID hc LABELS housecode.en cycle ID uc LABELS unitcode.en cycle ID fnc LABELS pfunc.en string ID dcstr CONTENT pdesc.en if vpkt = 1 then call reply(packet,0);vpkt=0 return newgd: /* Simply clears all fields */ address EZHOMEMUI list ID LIST1 ATTRS MUIA_List_Active popasl ID args CONTENT cycle ID hc LABELS '-' cycle ID uc LABELS '-' cycle ID fnc LABELS '-' string ID DCSTR CONTENT '' if vpkt = 1 then call reply(packet,0);vpkt=0 return test: address EZHOMEMUI check ID tstsx ; showit = result if showit = '0' then address command 'run >NIL:' pcommand.en else address command 'run <NIL: >CON:100/100/400/100/EZHomeTestAction/Close' pcommand.en drop showit if vpkt = 1 then call reply(packet,0);vpkt=0 if showlist('P', EZHOME) then do call statusrep() call devstatus() end return ezhd: /* EZHomeD control */ address EZHOMEMUI if ~showlist('P', 'EZHOME') then address command 'run >nil: EZHome' else if showlist('P', 'EZHOME') then address command 'rx "address EZHOME quit"' call delay(50) call refresh(0) if vpkt = 1 then call reply(packet,0);vpkt=0 return about: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI button ID about ATTRS MUIA_Disabled 1 AboutWindow = 'window ID about' AboutWindow group HORIZ button PICT "EZHome:Images/ezs.iff" /*TRANS*/ ATTRS MUIA_Background MUII_WindowBack MUIA_Frame MUIV_Frame_None text ATTRS MUIA_Background MUII_WindowBack MUIA_Frame MUIV_Frame_None LABEL VER"\nEZHomeD" EZHomeD_Ver "© 1996-2000 EzSoft\n by Jim Hines and Gene Heskett\n\n"EZHome_REG"\nSee docs for more info.\n\nCopyright 1996-2000 EZSoft" endgroup group HORIZ space HORIZ button PRESS COMMAND closeabout PORT EZHOMEPREFS ATTRS MUIA_Text_HiChar c2d('O') MUIA_ControlChar c2d('o') LABEL "Ok" space HORIZ endgroup endwindow return closeabout: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI AboutWindow CLOSE button ID about ATTRS MUIA_Disabled 0 return ldgad: mod = 0 argname = rtfilerequest('EZHome:ConfigFiles', , 'Pick a config file to load', 'OK', 'rt_reqpos = reqpos_centerscr') if argname ~= '' then do address command 'copy' argname 'EZHome:prefs/Action.prefs' call openprefs() en = 0 call refresh(1) end if vpkt = 1 then call reply(packet,0);vpkt=0 return svgad: argname = rtfilerequest('EZHome:ConfigFiles', , 'Enter filename to save', OK, 'rt_reqpos = reqpos_centerscr') if argname ~= '' then do if exists(argname) then do /*call rtezrequest('The file'||LF||argname||LF||'already exists.'||LF||'Do you wish to overwrite it?', 'Yes|Cancel', , 'rt_reqpos = reqpos_centerscr')*/ address EZHOMEMUI request TITLE '"EZHome Message"' GADGETS '"Yes|Cancel"' 'The file' argname '\nalready exists.\nDo you wish to overwrite it?' if result = 1 then address command 'delete' argname 'FORCE >NIL:' end call open('aprefs', argname, W) do qq = 1 to (count-1) call writeln('aprefs',housecode.qq||unitcode.qq','pfunc.qq','pcommand.qq','pdesc.qq',') end call close('aprefs') mod = 0 address command 'copy' argname 'EZHome:prefs/Action.prefs' if vpkt = 1 then call reply(packet,0);vpkt=0 if showlist('P', EZHOME) then address EZHOME readprefs /* Notify EZHomeD of the change */ end return refresh: if disclose = 1 then say 'refresh: arg(1)='arg(1) if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI if ~showlist('P', 'EZHOME') then do button ID ezhd LABEL "Inactive" end else if showlist('P', 'EZHOME') then do button ID ezhd LABEL "Active" end callhook ID LIST1 COMMAND """nullcommand""" PORT EZHOMEPREFS ATTRS MUIA_List_Active MUIV_EveryTime /* Re-direct Notify */ method ID LIST1 MUIM_List_Clear list ID LIST1 ATTRS MUIA_List_Quiet 1 /* Turn off listview redraw */ do qq = 1 to count-1 if pos('!',command.qq) > 0 then list ID LIST1 INSERT POS MUIV_List_Insert_Bottom STRING '\0335'pdesc.qq else list ID LIST1 INSERT POS MUIV_List_Insert_Bottom STRING '\0332'pdesc.qq end list ID LIST1 ATTRS MUIA_List_Quiet 0 method ID LIST1 MUIM_List_Select en-1 MUIV_List_Select_On 0 /* Select last selected entry */ callhook ID LIST1 COMMAND """LIST1""" PORT EZHOMEPREFS ATTRS MUIA_List_Active MUIV_EveryTime /* Re-Activate Notify */ return refreshfile: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI if ~showlist('P', 'EZHOME') then do button ID ezhd LABEL "Inactive" end else if showlist('P', 'EZHOME') then do button ID ezhd LABEL "Active" end callhook ID LIST1 COMMAND LIST1 PORT EZHOMEPREFS ATTRS MUIA_List_Active MUIV_EveryTime /* Re-direct Notify */ method ID LIST1 MUIM_List_Clear do qq = 1 to count drop phcode.qq drop pfunc.qq drop pcommand.qq drop pdesc.qq drop housecode.qq drop unitcode.qq end callhook ID LIST1 COMMAND LIST1 PORT EZHOMEPREFS ATTRS MUIA_List_Active MUIV_EveryTime /* Re-Activate Notify */ call openprefs() /* Re-read action.prefs */ list ID LIST1 ATTRS MUIA_List_Quiet 1 /* Re-Insert listview */ do qq = 1 to next list ID LIST1 INSERT POS STRING MUIV_List_Insert_Bottom STRING pdesc.qq end list ID LIST1 ATTRS MUIA_List_Quiet 0 return delete: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI mod = 1 MUIA_List_Active = '0x8042391c' MUIA_List_Entries = '0x80421654' MUIM_Busy_Move = '0x80020001' list ID LIST1 ATTRS MUIA_List_Active ; position = result+1 /* Get position to delete */ list ID LIST1 POS position ; line = result /* Get line content to delete */ list ID LIST1 POS position-1 STRING /* Delete line in list */ list ID LIST1 ATTRS MUIA_List_Entries ; newentries = result /* Update counters */ do qq = (position+1) to count rr = qq-1 phcode.rr = phcode.qq pfunc.rr = pfunc.qq pcommand.rr = pcommand.qq pdesc.rr = pdesc.qq housecode.rr = housecode.qq unitcode.rr = unitcode.qq end drop phcode.count pfunc.count pcommand.count pdesc.count housecode.count unitcode.count count = count - 1 return args: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI mod = 1 list ID LIST1 ATTRS MUIA_List_Active ; position = result+1 popasl ID args ; comm = result pcommand.position = comm return hc: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI mod = 1 list ID LIST1 ATTRS MUIA_List_Active ; position = result+1 cycle ID hc ; hcode = result phcode.position = hcode||unitcode.position housecode.position = hcode return uc: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI mod = 1 list ID LIST1 ATTRS MUIA_List_Active ; position = result+1 cycle ID uc ; ucode = result pucode.position = housecode.position||ucode unitcode.position = ucode return fnc: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI mod = 1 list ID LIST1 ATTRS MUIA_List_Active ; position = result+1 cycle ID fnc ; fcode = result pfunc.position = fcode return adgad: /* call auxwin() */ if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI mod = 1 popasl ID args ; argstmp = result if argstmp = '' then do call message('No Command Entered') return end cycle ID hc ; hctmp = result cycle ID uc ; uctmp = result cycle ID fnc ; fnctmp = result desc = rtgetstring(,'Please Enter a Description', 'Description Requester', 'Okay|Cancel') if rtresult == 1 then desc = desc if rtresult == 0 then return /* call waitforpkt() */ list ID LIST1 NODUP POS MUIV_List_Insert_Bottom INSERT STRING desc /* Insert new item */ if count = 0 then do /* Take care of very first entry */ phcode.1 = hctmp||uctmp pfunc.1 = fnctmp pcommand.1 = argstmp pdesc.1 = desc housecode.1 = hctmp unitcode.1 = uctmp count = count + 1 end else do phcode.count = hctmp||uctmp pfunc.count = fnctmp pcommand.count = argstmp pdesc.count = desc housecode.count = hctmp unitcode.count = uctmp end count = count+1 return /* ================= REALTIME WINDOW =================== */ labels: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI cycle ID rcyc ; rhouse = result if exists('EZHome:prefs/Labels/HC_'rhouse'.prefs') then do call open('hcconfig','EZHome:Prefs/Labels/HC_'rhouse'.prefs','R') do qq = 1 to 16 hcuser.qq = readln('hcconfig') end call close('hcconfig') end else do qq = 1 to 16 hcuser.qq = qq end do qq = 1 to 16 string ID rc.qq CONTENT hcuser.qq end return list2: if vpkt = 1 then call reply(packet,0) ; vpkt=0 address EZHOMEMUI list ID LIST2 ATTRS MUIA_List_Active en = RESULT+1 /* en is the event number */ address command 'run >NIL:' user.en return _on: if vpkt = 1 then call reply(packet,0) ; vpkt=0 if ~showlist('P',EZHOME) then do call message('EZHome Daemon is not running') return end address EZHOMEMUI cycle ID rcyc ; rhouse = result cycle ID _on||qq ; func = result if disclose = 1 then say '_on: func='func 'arg(1)='arg(1) 'len(arg(1)='length(arg(1))' : send 'rhouse||arg(1) upper(func) if func ~= 'Dim' then address EZHOME send rhouse||arg(1) upper(func) /* Send it again if errored */ text ID rlast LABEL rhouse||qq /* write the text gad */ /*if func = 'Off' then popslider ID _dm||qq ATTRS MUIA_Slider_Level 0*/ return _dimit: if vpkt = 1 then call reply(packet,0);vpkt=0 if ~showlist('P',EZHOME) then do call message('EZHome Daemon is not running') return end /* else its running */ address EZHOMEMUI cycle ID rcyc ; rhouse = result cycle ID _on||qq ; tfunc = result /* save current button status */ text ID rlast LABEL rhouse||qq /* write the text gad */ popslider ID _dm||qq rdimlevel = result if pos('-', rdimlevel) > 0 then do func = 'DIM' rdimlevel = delstr(rdimlevel,1,1) end else func = 'BRIGHT' if tfunc = 'Off' then do /* if off, first we turn it on, then we set brightness but we need to shut the daemon up for this */ call closeport('EZHOMEPREFS') /* make us dissappear, also saves beaucoup time */ if disclose = 1 then say '_dimit: address EZHOME send' rhouse||qq 'ON' address EZHOME send rhouse||qq 'ON' call openport('EZHOMEPREFS') end /* it was already on, (or dimmed) so do this only */ if disclose = 1 then say '_dimit: address EZHOME send' rhouse||qq upper(func) rdimlevel address EZHOME send rhouse||qq upper(func) rdimlevel return rAllLightsOn: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI cycle ID rcyc ; rhouse = result if ~showlist('P',EZHOME) then call message('EZHome Daemon is not running') else address EZHOME send rhouse'1' AllLightsOn return rAllLightsOff: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI cycle ID rcyc ; rhouse = result if ~showlist('P',EZHOME) then call message('EZHome Daemon is not running') else address EZHOME send rhouse'1' AllLightsOff return rAllUnitsOff: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI cycle ID rcyc ; rhouse = result if ~showlist('P',EZHOME) then call message('EZHome Daemon is not running') else address EZHOME send rhouse'1' AllUnitsOff return AddMacro: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI /* button ID dtwin ATTRS MUIA_Disabled 1*/ AddMacWindow = window ID AddMac ATTRS MUIA_Window_ScreenTitle """EZHomePrefs v1.0 beta by Jim Hines. ©1998 EZSoft""" TITLE """Add Macro""" AddMacWindow group label CENTER 'Enter Macro Definition\nUse format \033bLabel,Field' string ID admac COMMAND 'addmacro' PORT EZHOMEPREFS endgroup group HORIZ button LABEL "Okay" button COMMAND cancelreq1 PORT EZHOMEPREFS LABEL "Cancel" endgroup endwindow return CancelWin: /* This is made to work as generic as possible */ if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI tmp = arg(1) tmp CLOSE drop tmp return DelMacro: if vpkt = 1 then call reply(packet,0);vpkt=0 return /* ================= PREFERENCES WINDOW =================== */ sethouse: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI cycle ID hcpref ; hcprefs = result IF disclose = 1 then say 'sethouse: hcprefs='hcprefs if showlist('P', EZHOME) then do if disclose = 1 then say 'sethouse: address EZHOME sethouse' hcprefs address EZHOME SETHOUSE hcprefs end cycle ID rcyc LABEL hcprefs /* Set Realtime House */ drop hcprefs return saveprefs: /* Save Global Prefs */ if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI string ID loggad ; pref.1 = result string ID devgad ; pref.2 = result string ID unit ; pref.3 = result cycle ID hcpref ; tmppref = result ; call cvthouseasc() /* pref.4 is returned var */ check ID logsx ; pref.5 = result check ID tstsx ; pref.6 = result call open('gprefs', 'EZHome:Prefs/ezhome.prefs', W) do i = 1 to 6 call writeln('gprefs',pref.i) end call close('gprefs') /* Save Label Names */ cycle ID rcyc ; rhouse = result call open('lprefs', 'EZHome:Prefs/Labels/HC_'rhouse'.prefs', W) do qq = 1 to 16 string ID rc.qq ; read.qq = result call writeln('lprefs',read.qq) end call close('lprefs') if showlist('P', EZHOME) then address EZHOME readprefs return setclock: if vpkt = 1 then call reply(packet,0);vpkt=0 if showlist('P', EZHOME) then address EZHOME setclock return batteryrst: if vpkt = 1 then call reply(packet,0);vpkt=0 if showlist('P', EZHOME) then do address EZHOMEMUI request TITLE '"Battery Timer Reset"' GADGETS '"Yes|Cancel"' '"\033cThis command should only be\nissued after installing new batteries.\nAre you sure?"' if result = 1 then address EZHOME battreset call statusrep() call devstatus() end else call message('EZHome Daemon is not running') return /* ================= */ openprefs: /* Open Action Prefs */ if vpkt = 1 then call reply(packet,0);vpkt=0 next = 0 count = 0 /* Keeps track of amount of entries */ if disclose = 1 then say 'Reading Action.prefs' if exists('EZHome:Prefs/Action.prefs') then do call open('aprefs', 'EZHome:Prefs/Action.prefs', R) do until eof('aprefs') linein = readln('aprefs') if pos(';',linein) = 1 then iterate next = next + 1 count = count + 1 parse var linein line ';' parse var line phcode.next','pfunc.next','pcommand.next','pdesc.next',' housecode.next = left(phcode.next,1) if length(phcode.next) = 3 then do unitcode.next = right(phcode.next,2) end else unitcode.next = right(phcode.next,1) end call close('aprefs') end else call message('No Action.prefs file exists') /* Read Macro Prefs */ next2 = 0 if disclose = 1 then say 'Reading Macro.prefs' if exists('EZHome:Prefs/Macro.prefs') then do call open('mprefs', 'EZHome:Prefs/Macro.prefs', R) do until eof('mprefs') linein = readln('mprefs') if pos(';',linein) = 1 then iterate next2 = next2 + 1 parse var linein line ';' parse var line username.next2','user.next2 end call close('mprefs') user.0 = next2 end /* Read NameCode Prefs */ if exists('EZHome:prefs/Labels/HC_'pdefhouse'.prefs') then do call open('hcconfig','EZHome:Prefs/Labels/HC_'pdefhouse'.prefs','R') do qq = 1 to 16 hcuser.qq = readln('hcconfig') end call close('hcconfig') end else do qq = 1 to 16 hcuser.qq = qq end return auxwin: if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI AuxWindow = "window ID Aux" AuxWindow label CENTER 'Please enter a description' string ID auxst group HORIZ button COMMAND """test9""" PORT EZHOMEPREFS label 'Okay' button COMMAND """"AuxWindow" CLOSE""" PORT EZHOMEMUI ATTRS MUIA_Text_HiChar c2d('O') MUIA_ControlChar c2d('o') label 'Cancel' endgroup endwindow return cvthousehex: if pdefhouset = '6' then pdefhouse = 'A' if pdefhouset = 'E' then pdefhouse = 'B' if pdefhouset = '2' then pdefhouse = 'C' if pdefhouset = 'A' then pdefhouse = 'D' if pdefhouset = '1' then pdefhouse = 'E' if pdefhouset = '9' then pdefhouse = 'F' if pdefhouset = '5' then pdefhouse = 'G' if pdefhouset = 'D' then pdefhouse = 'H' if pdefhouset = '7' then pdefhouse = 'I' if pdefhouset = 'F' then pdefhouse = 'J' if pdefhouset = '3' then pdefhouse = 'K' if pdefhouset = 'B' then pdefhouse = 'L' if pdefhouset = '0' then pdefhouse = 'M' if pdefhouset = '8' then pdefhouse = 'N' if pdefhouset = '4' then pdefhouse = 'O' if pdefhouset = 'C' then pdefhouse = 'P' return cvthouseasc: if tmppref = 'A' then pref.4 = '6' if tmppref = 'B' then pref.4 = 'E' if tmppref = 'C' then pref.4 = '2' if tmppref = 'D' then pref.4 = 'A' if tmppref = 'E' then pref.4 = '1' if tmppref = 'F' then pref.4 = '9' if tmppref = 'G' then pref.4 = '5' if tmppref = 'H' then pref.4 = 'D' if tmppref = 'I' then pref.4 = '7' if tmppref = 'J' then pref.4 = 'F' if tmppref = 'K' then pref.4 = '3' if tmppref = 'L' then pref.4 = 'B' if tmppref = 'M' then pref.4 = '0' if tmppref = 'N' then pref.4 = '8' if tmppref = 'O' then pref.4 = '4' if tmppref = 'P' then pref.4 = 'C' return /* ================= REALTIME WINDOW =================== */ statusrep: if vpkt = 1 then call reply(packet,0);vpkt=0 if showlist('P',EZHOME) then address EZHOME status else do call message('EZHome Daemon is not running') return end return devstatus: /* Get devstatus/dimstatus */ if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI /*0*/ bit = MAX(bittst(devstat1,0),(bittst(DimByte1,0)*2)) cycle ID _on13 LABELS StutusArray.bit bit = MAX(bittst(devstat2,0),(bittst(DimByte2,6)*0)) cycle ID _on14 LABELS StutusArray.bit /*1*/ bit = MAX(bittst(devstat1,1),(bittst(DimByte1,1)*2)) cycle ID _on5 LABELS StutusArray.bit bit = MAX(bittst(devstat2,1),(bittst(DimByte2,1)*2)) cycle ID _on6 LABELS StutusArray.bit /*2*/ bit = MAX(bittst(devstat1,2),(bittst(DimByte1,2)*2)) cycle ID _on3 LABELS StutusArray.bit bit = MAX(bittst(devstat2,2),(bittst(DimByte2,2)*2)) cycle ID _on4 LABELS StutusArray.bit /*3*/ bit = MAX(bittst(devstat1,3),(bittst(DimByte1,3)*2)) cycle ID _on11 LABELS StutusArray.bit bit = MAX(bittst(devstat2,3),(bittst(DimByte2,3)*2)) cycle ID _on12 LABELS StutusArray.bit /*4*/ bit = MAX(bittst(devstat1,4),(bittst(DimByte1,4)*2)) cycle ID _on15 LABELS StutusArray.bit bit = MAX(bittst(devstat2,4),(bittst(DimByte2,4)*2)) cycle ID _on16 LABELS StutusArray.bit /*5*/ bit = MAX(bittst(devstat1,5),(bittst(DimByte1,5)*2)) cycle ID _on7 LABELS StutusArray.bit bit = MAX(bittst(devstat2,5),(bittst(DimByte2,5)*2)) cycle ID _on8 LABELS StutusArray.bit /*6*/ bit = MAX(bittst(devstat1,6),(bittst(DimByte1,6)*2)) cycle ID _on1 LABELS StutusArray.bit bit = MAX(bittst(devstat2,6),(bittst(DimByte2,6)*2)) cycle ID _on2 LABELS StutusArray.bit /*7*/ bit = MAX(bittst(devstat1,7),(bittst(DimByte1,7)*2)) cycle ID _on9 LABELS StutusArray.bit bit = MAX(bittst(devstat2,7),(bittst(DimByte2,7)*2)) cycle ID _on10 LABELS StutusArray.bit /*MISC*/ text ID CM1 LABEL "\033b"CM11A_Time text ID CM2 LABEL CM11A_Day text ID CM3 LABEL "It is" CM11A_DayNum "days into this year" text ID CM4 LABEL "CM11A Revision" CM11A_Rev batlevel = (1 - (battimer / batterytype)) * 100 gauge ID batmt ATTRS MUIA_Gauge_Current batlevel MUIA_Gauge_Horiz LABEL "Battery Level %ld" /* Set battery strength meter */ cycle ID rcyc LABEL rethouse /* Set Realtime House */ cycle ID hcpref LABEL rethouse /* Set Monitored House */ return /* ================= */ message: procedure /*call rtezrequest(arg(1),'OK','EZHome Message','rtez_flags=ezreqf_centertext')*/ if vpkt = 1 then call reply(packet,0);vpkt=0 address EZHOMEMUI request TITLE '"EZHome Message"' GADGETS '"Okay"' arg(1) return syntax: ioerr: error: errorrc = RC address EZHOMEMUI request TITLE '"EZHomePrefs Fatal Error"' GADGETS '"Okay"' 'EZHomePrefs has exited with an error.\nLine' SIGL '- -' ERRORTEXT(errorrc) call exiting() exiting: break_c: if vpkt = 1 then call reply(packet,0) if mod = 1 then do address EZHOMEMUI request TITLE '"EZHome Message"' GADGETS '"Yes|No"' '"File has changed.\nDo you want to save it?"' if result = 1 then call svgad() end if ~(showlist('P','EZHOME')) then do address EZHOMEMUI request TITLE '"EZHome Message"' GADGETS '"Yes|No"' '"EZHome Daemon is not running.\nDo you want to run it?"' if result = 1 then address command 'run >nil: EZHome' end call closeport('EZHOMEPREFS') address EZHOMEMUI quit /* Shut down MUIREXX... */ exit